// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlGetCalendarsRequestParameters : RequestParameters<MlGetCalendarsRequestParameters>
	{
		[JsonIgnore]
		public int? From { get => Q<int?>("from"); set => Q("from", value); }

		[JsonIgnore]
		public int? Size { get => Q<int?>("size"); set => Q("size", value); }
	}

	public sealed partial class MlGetCalendarsRequest : PlainRequestBase<MlGetCalendarsRequestParameters>
	{
		public MlGetCalendarsRequest()
		{
		}

		public MlGetCalendarsRequest(Elastic.Clients.Elasticsearch.Id? calendar_id) : base(r => r.Optional("calendar_id", calendar_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetCalendars;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public int? From { get => Q<int?>("from"); set => Q("from", value); }

		[JsonIgnore]
		public int? Size { get => Q<int?>("size"); set => Q("size", value); }

		[JsonInclude]
		[JsonPropertyName("page")]
		public Elastic.Clients.Elasticsearch.Ml.Page? Page { get; set; }
	}

	public sealed partial class MlGetCalendarsRequestDescriptor : RequestDescriptorBase<MlGetCalendarsRequestDescriptor, MlGetCalendarsRequestParameters>
	{
		internal MlGetCalendarsRequestDescriptor(Action<MlGetCalendarsRequestDescriptor> configure) => configure.Invoke(this);
		public MlGetCalendarsRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetCalendars;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlGetCalendarsRequestDescriptor From(int? from) => Qs("from", from);
		public MlGetCalendarsRequestDescriptor Size(int? size) => Qs("size", size);
		public MlGetCalendarsRequestDescriptor CalendarId(Elastic.Clients.Elasticsearch.Id? calendar_id)
		{
			RouteValues.Optional("calendar_id", calendar_id);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Ml.Page? PageValue { get; set; }

		private PageDescriptor PageDescriptor { get; set; }

		private Action<PageDescriptor> PageDescriptorAction { get; set; }

		public MlGetCalendarsRequestDescriptor Page(Elastic.Clients.Elasticsearch.Ml.Page? page)
		{
			PageDescriptor = null;
			PageDescriptorAction = null;
			PageValue = page;
			return Self;
		}

		public MlGetCalendarsRequestDescriptor Page(PageDescriptor descriptor)
		{
			PageValue = null;
			PageDescriptorAction = null;
			PageDescriptor = descriptor;
			return Self;
		}

		public MlGetCalendarsRequestDescriptor Page(Action<PageDescriptor> configure)
		{
			PageValue = null;
			PageDescriptor = null;
			PageDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (PageDescriptor is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageDescriptor, options);
			}
			else if (PageDescriptorAction is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, new PageDescriptor(PageDescriptorAction), options);
			}
			else if (PageValue is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageValue, options);
			}

			writer.WriteEndObject();
		}
	}
}